package com.awifi.com.thread.synchornized;

/**
 * @description: ToDo
 * @author: marin
 * @time: 2020/6/28 18:16
 */
public class RunableImpl implements Runnable {

    private int ticket = 100;
    Object object = new Object();

    @Override
    public void run() {
        while (true){
            synchronized (object) {
                if(ticket>0){
                    ticket--;
                    System.out.println(Thread.currentThread().getName()+"正在卖第"+ticket+"张票");
                }
            }
        }
    }
}
